/*
 * @Author: 吉治浩
 * @Date: 2021-08-27 11:25:38
 * @Phone: 17830209418
 * @QQ: 1625876875@qq.com
 */
import axios from "axios";
import { operationCtx } from "../../../utils/auth";
import store from "@/store";
import { httpBehaviorUrl, httpComputedUrl } from "@/utils/http";

const apiUrl = httpBehaviorUrl + "/backend/behavior/";
//后台计算
const apiUrlReport = httpBehaviorUrl + "/backend/behavior/";

// get
function getAction(url, parameter) {
  return axios({ url: url, method: "get", params: parameter });
}

// post
export function postAction(url, parameter) {
  parameter["operationCtx"] = operationCtx;
  parameter["req"]["appId"] = store.state.global.appId;
  parameter["req"]["requestId"] = require("node-uuid").v1();
  return axios({ url: url, method: "post", data: parameter });
}

//属性列表
const propertyList = (params) =>
  postAction(apiUrl + `property/properties`, params);

//事件列表
const thinglList = (params) => postAction(apiUrl + "events/all", params);

//分布分析计算
const userpathCount = (params) =>
  postAction(apiUrl + "userpath/report", params);

//属性值查询
const valueList = (params) => postAction(apiUrl + "property/values", params);

//获取属性分析结果
const attributionFunnel = (params) =>
  postAction(apiUrlReport + `attribution/analyse`, params);

export {
  propertyList, //属性列表
  thinglList, //事件列表
  userpathCount, //分布分析计算
  valueList, //属性值查询
  attributionFunnel,
};
